<?php
include_once("../configure/admin.config.inc.php");//--> admin global var
include_once("db.inc.php");						//--> db global var
include_once("Smarty.class.php");				//--> out template
include_once("Operation.php");					//--> Operation
include_once("MenuGroup.php");					//--> Menu group class
require_once("controlHeader.php");				//--> system control header

$objOperate		= new Operation($sessionImpl->getLanguage());			//--> Operation instance
$objMenuGroup 	= new MenuGroup($sessionImpl->getLanguage(), $uid);		//--> Menu group instance

$error_message 		= '';
$strMenuGroupName 	= '';
$strMenuGroupNameCN = '';

$arrOperate 	= $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_POST['Submit'])){
	$strOrders 			= $_POST['orders'];
	$strMenuGroupName 	= $_POST['menuGroupName'];
	
	if(!empty($strMenuGroupName)){
		$isReturn = $objMenuGroup->add($arrOperate, $strOrders, $strMenuGroupName);
		if($isReturn)
			$error_message = 'add menu group successfully.';
		else 
			$error_message = 'add menu group fail.';
	}else{
		$error_message = 'The menu group name should\'t be empty.';
	}
}

/*----- out html -----*/
$smarty = new Smarty();					//----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir  = CACHE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);

$smarty->assign('backurl',$backurl);
$smarty->assign('error_message', $error_message);

$smarty->assign('orders', $strOrders);
$smarty->assign('menuGroupName', $strMenuGroupName);

$smarty->display('listMenuGroup_add.htm');
?>
